var kidsprotector = {
  onLoad: function() {
    // initialization code
    this.initialized = true;
    this.strings = document.getElementById("kidsprotector-strings");
	var appcontent = document.getElementById("appcontent");   // browser
	if(appcontent)
		appcontent.addEventListener("DOMContentLoaded", kidsprotector.onPageLoad, true);
	var messagepane = document.getElementById("messagepane"); // mail
	if(messagepane)
		messagepane.addEventListener("load", function(event) { kidsprotector.onPageLoad(event); }, true);
  },

  onPageLoad: function(aEvent) {
	var doc = aEvent.originalTarget;
	var win = doc.defaultView;
	if (myExtension.average > 0) {
		// doc.body.style.display = "none";
		switch(myExtension.average) {
			case "1":
				age = 10;
				break;
			case "2":
				age = 16;
				break;
			case "3":
				age = 18;
				break;
			default:
				break;
		}
		doc.body.innerHTML = "<div style=\"background:#FFF;height:100%;color:black;text-align:center;font-size:50px;\">ACCESS DENIED!<br /><span style=\"font-size:20px;\">This website is forbidden for people less than "+age+".</span></div>";
	}
  },
  
  onMenuItemCommand: function(e) {
    var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
                                  .getService(Components.interfaces.nsIPromptService);
    promptService.alert(window, this.strings.getString("helloMessageTitle"),
                                this.strings.getString("helloMessage"));
  },

  onToolbarButtonCommand: function(e) {
    content.wrappedJSObject.location='http://localhost:1251/Notation.aspx?s='+myExtension.oldURL;
    kidsprotector.onMenuItemCommand(e);
  }
};

window.addEventListener("load", function () { kidsprotector.onLoad(); }, false);